package zhouzhouyongche.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import zhouzhouyongche.client_util.ClientOrder;
import zhouzhouyongche.service.OrderService;

@Controller
@Action(value = "order")
public class OrderAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	
	private int userId;
	private int passengerId;
	private int ticketId;
	private int seatNumber;
	private String orderCode;
	private int ticketPickerId;
	private String phoneNumberOfTicketPicker; 
	
	@Autowired
	private OrderService orderService;
	
	//如果座位已经被预订
	public void saveOrder() {
		int result = orderService.saveOrder(userId, passengerId, ticketId, seatNumber, ticketPickerId, phoneNumberOfTicketPicker);
		writeJson(result);
	}

	public void getOrders() {
		List<ClientOrder> orders = orderService.getOrders(userId);
		writeJson(orders.size(), orders);
	}
	
	public void cancelOrder() {
		orderService.cancelOrder(orderCode);//orderCode
	}
	
	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getPassengerId() {
		return passengerId;
	}

	public void setPassengerId(int passengerId) {
		this.passengerId = passengerId;
	}

	public int getSeatNumber() {
		return seatNumber;
	}

	public void setSeatNumber(int seatNumber) {
		this.seatNumber = seatNumber;
	}

	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	public int getTicketId() {
		return ticketId;
	}

	public void setTicketId(int ticketId) {
		this.ticketId = ticketId;
	}

	public int getTicketPickerId() {
		return ticketPickerId;
	}

	public void setTicketPickerId(int ticketPickerId) {
		this.ticketPickerId = ticketPickerId;
	}

	public String getPhoneNumberOfTicketPicker() {
		return phoneNumberOfTicketPicker;
	}

	public void setPhoneNumberOfTicketPicker(String phoneNumberOfTicketPicker) {
		this.phoneNumberOfTicketPicker = phoneNumberOfTicketPicker;
	}

}
